/*
 * mingw doesn't contain all the headers from the PlatformSDK.
 * Specifically it's missing the MSI header files.
 *
 * All defines in this file are copied *without change* from the
 * PlatformSDK header files.
 */



/* Stuff from msi.h! */
UINT WINAPI MsiSetPropertyA(
  MSIHANDLE hInstall,
  LPCTSTR szName,
  LPCTSTR szValue
);
UINT WINAPI MsiSetPropertyW(
  MSIHANDLE hInstall,
  LPCWSTR szName,
  LPCWSTR szValue
);

UINT WINAPI MsiGetPropertyA(
  MSIHANDLE hInstall,
  LPCTSTR szName,
  LPTSTR szValueBuf,
  DWORD* pchValueBuf
);
UINT WINAPI MsiCloseHandle(
  MSIHANDLE hAny);
typedef enum tagINSTALLMESSAGE
{
	INSTALLMESSAGE_FATALEXIT      = 0x00000000L, // premature termination, possibly fatal OOM
	INSTALLMESSAGE_ERROR          = 0x01000000L, // formatted error message
	INSTALLMESSAGE_WARNING        = 0x02000000L, // formatted warning message
	INSTALLMESSAGE_USER           = 0x03000000L, // user request message
	INSTALLMESSAGE_INFO           = 0x04000000L, // informative message for log
	INSTALLMESSAGE_FILESINUSE     = 0x05000000L, // list of files in use that need to be replaced
	INSTALLMESSAGE_RESOLVESOURCE  = 0x06000000L, // request to determine a valid source location
	INSTALLMESSAGE_OUTOFDISKSPACE = 0x07000000L, // insufficient disk space message
	INSTALLMESSAGE_ACTIONSTART    = 0x08000000L, // start of action: action name & description
	INSTALLMESSAGE_ACTIONDATA     = 0x09000000L, // formatted data associated with individual action item
	INSTALLMESSAGE_PROGRESS       = 0x0A000000L, // progress gauge info: units so far, total
	INSTALLMESSAGE_COMMONDATA     = 0x0B000000L, // product info for dialog: language Id, dialog caption
	INSTALLMESSAGE_INITIALIZE     = 0x0C000000L, // sent prior to UI initialization, no string data
	INSTALLMESSAGE_TERMINATE      = 0x0D000000L, // sent after UI termination, no string data
	INSTALLMESSAGE_SHOWDIALOG     = 0x0E000000L, // sent prior to display or authored dialog or wizard
} INSTALLMESSAGE;


typedef enum tagMSIMODIFY
{
    MSIMODIFY_REFRESH          = 0,  // refetch current record data
    MSIMODIFY_INSERT           = 1,  // insert new record, fails if matching key exists
    MSIMODIFY_UPDATE           = 2,  // update existing non-key data of fetched record
    MSIMODIFY_ASSIGN           = 3,  // insert record, replacing any existing record
    MSIMODIFY_REPLACE          = 4,  // update record, delete old if primary key edit
    MSIMODIFY_MERGE            = 5,  // fails if record with duplicate key not identical
    MSIMODIFY_DELETE           = 6,  // remove row referenced by this record from table
    MSIMODIFY_INSERT_TEMPORARY = 7,  // insert a temporary record
    MSIMODIFY_VALIDATE         = 8,  // validate a fetched record
    MSIMODIFY_VALIDATE_NEW     = 9,  // validate a new record
    MSIMODIFY_VALIDATE_FIELD   = 10, // validate field(s) of an incomplete record
    MSIMODIFY_VALIDATE_DELETE  = 11, // validate before deleting record
} MSIMODIFY;


/* msiquery.h */
MSIHANDLE WINAPI MsiCreateRecord(
	UINT cParams);                   // the number of data fields
UINT WINAPI MsiRecordSetStringW(MSIHANDLE hRecord,
	UINT iField,
	LPCWSTR      szValue);
int WINAPI MsiProcessMessage(MSIHANDLE hInstall,
	INSTALLMESSAGE eMessageType, // type of message
	MSIHANDLE hRecord);          // record containing message format and data


MSIHANDLE WINAPI MsiGetActiveDatabase(MSIHANDLE hInstall); // returns handle to database, 0 if none active

UINT WINAPI MsiDatabaseOpenViewA(MSIHANDLE hDatabase,
    LPCSTR     szQuery,            // SQL query to be prepared
    MSIHANDLE*  phView);            // returned view if TRUE

UINT WINAPI MsiRecordSetInteger(MSIHANDLE hRecord,
    unsigned int iField,
    int iValue);

// Copy a string into the designated field
// A null string pointer and an empty string both set the field to null
// Returns ERROR_SUCCESS, ERROR_INVALID_HANDLE, ERROR_INVALID_FIELD

UINT WINAPI MsiRecordSetStringA(MSIHANDLE hRecord,
    unsigned int iField,
    LPCSTR      szValue);


UINT WINAPI MsiViewModify(MSIHANDLE hView,
    MSIMODIFY eModifyMode,         // modify action to perform
    MSIHANDLE hRecord);            // record obtained from fetch, or new record

UINT WINAPI MsiViewClose(MSIHANDLE hView);    



